package com.hschinese.pronunciation.adapter;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.GridView;

import com.hschinese.pronunciation.R;
import com.hschinese.pronunciation.activity.StudayREcognitionContentActivity;
import com.hschinese.pronunciation.bean.AppDataBean;
import com.hschinese.pronunciation.bean.ListViewItem;

import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;
import studychinese.adapters.AppAdapter;


/**
 * zf 创建于 2017/3/31 16:25.
 */

public class StudayRecogintionListAdapter extends AppAdapter {
    public static int listPos = 0;

    private Context mContext;
    public StudayRecogintionListAdapter(List list, Context context) {
        super(list, context);
        this.mContext=context;
    }

    @Override
    public int getViewTypeCount() {
        return super.getViewTypeCount();
    }

    @Override
    public int getItemViewType(int position) {
        return super.getItemViewType(position);
    }

    @Override
    public int getCount() {
        return super.getCount();
    }


    @Override
    public View createView(final int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder = null;
        if (convertView == null) {
            convertView = View.inflate(context, R.layout.item_city_list, null);
            viewHolder = new ViewHolder(convertView);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }

        final List<String> list_city = new ArrayList<>();
        ListViewItem item = (ListViewItem) list.get(position);
        final List<AppDataBean> mWords = item.mWords;
        CityChrildGridViewAdapter lunTanDetailListListAdapter = new CityChrildGridViewAdapter(mWords, context);
        viewHolder.gv_citylist.setAdapter(lunTanDetailListListAdapter);

        viewHolder.gv_citylist.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                AppDataBean appDataBean = mWords.get(i);
                Intent intent = new Intent(mContext, StudayREcognitionContentActivity.class);
                intent.putExtra("lesson",appDataBean.getType());
                int positionInVowel = getPositionInVowel(appDataBean.getGroupID(), i);
                intent.putExtra("position",positionInVowel);
                intent.putExtra("groupID",appDataBean.getGroupID());

                mContext.startActivity(intent);
            }
        });

        return convertView;
    }

    private int getPositionInVowel(int gid, int pos) {
        int position = 0;

            position = pos;

        return position;
    }
    static class ViewHolder {




        @Bind(R.id.gv_citylist)
        GridView gv_citylist;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
